<?php
//Documento
$objeto="Cajero";
$nombre_subsec="cajeros";
//base de datos
$prefijo="caj";
$tabla=$prefijo."_cajeros";
$codigo_nombre=$prefijo."_codigo";
//campos
$campos_tabla= $campos = array("Codigo","Descripcion","Nombre","Email","Direccion","Telefono","Celular");

//Variables
include "includes/conexion.php";
include "includes/funciones.php";
function activo($li){
	if(isset($_GET["subsec"])){
		$acc=$_GET["subsec"];			
				;if($acc==$li){
				echo "class='current'";	
					}
	}
}
if (isset($_GET["borrar"])){
	$id=$_GET["borrar"];
	$c="delete from $tabla where $codigo_nombre='$id'";
	delete($c);
	$url = $_SERVER['PHP_SELF'];  
}

include "segunda_barra.php";
?>


<!-- CONTENT START -->
    <div class="grid_16" id="content">
    <!--  TITLE START  --> 
    <div class="grid_9">
    <h1 class="dashboard">Mantencion <?php 
 if(isset($_GET["subsec"])){
    	echo "de ".ucfirst($_GET["subsec"]);
 }
  
     ?></h1>
    </div>
    <!--RIGHT TEXT/CALENDAR
    <div class="grid_6" id="eventbox"><a href="#" class="inline_calendar">You don't have any events for today! Yay!</a>
    	<div class="hidden_calendar"></div>
    </div> 
    RIGHT TEXT/CALENDAR END-->
    <div class="clear">
    </div>
    <!--  TITLE END  -->    
    <!-- #PORTLETS START -->
    <div id="portlets">
    <!-- FIRST SORTABLE COLUMN START -->
     
      <!-- FIRST SORTABLE COLUMN END -->
      <!-- SECOND SORTABLE COLUMN START -->
 
	<!--  SECOND SORTABLE COLUMN END -->
    <div class="clear"></div>
    <!--THIS IS A WIDE PORTLET-->
    <div class="portlet">
        <div class="portlet-header fixed"><img src="images/icons/user.gif" width="16" height="16" alt="Latest Registered Users" /> Lista de <?php echo $nombre_subsec;?> registrados
        	<?php	if(isset($_POST["error"])){echo "<p class='info' id='error'><span class='info_inner'>".$_POST["error"]."</span></p>";}?></div>
		 <?php
     $orden="cat_codigo";
     //$tabla="cat_categoria";
	 $consulta = "select * from $tabla";
	$subsec=$_GET["subsec"];
	 
if(isset($_POST["do"])){
	if($_POST["do"]=="filtrar"){
				 $termino=str_replace('*', '%', $_POST["buscar"]);
$consulta.="  WHERE caj_nombre_completo LIKE '$termino' OR caj_descripcion LIKE '$termino' ";
	}
	else{
		$consulta.=" order by $orden desc";}
 //echo $consulta;

	}
$_SESSION["ultima_consulta"]=$consulta;
?>
		<!--FORMULARIO DE FILTRO -->
          <div id="filtro">
                <form id="frm_filtro" name ="frm_filtro" method="post" action="menu.php?sec=mantencion&subsec=<?php echo $subsec?>">
                 <li><input type="text" name="buscar" size="25" placeholder="Buscar..." /></li>
                <li>
                    <button type="submit" id="do" name="do" value="filtrar">Filtrar</button>
                </li>
                <li>
                  <button type="submit" id="do" name="do" value="todos">Todos</button>
                </li>
            </ul>
        </form>
       </div>
       <!--FIN FILTRO-->
		<div class="portlet-content nopadding">
        <form action="" method="post">
          <table width="100%" cellpadding="0" cellspacing="0" id="box-table-a" summary="Employee Pay Sheet">
            <thead >
              <tr>
                 <!--<th width="34" scope="col"><input type="checkbox" name="allbox" id="allbox" onclick="checkAll()" /></th> -->
                 <?php
                 foreach ($campos_tabla as $campos => $campos_t) {
                     echo "<th width='136' scope='col'>$campos_t</th>";
                 }
                 ?>
                <th width="90" scope="col">Acciones</th>
              </tr>
            </thead>
            <tbody">
            	<!-- fila -->
<?php
//$consulta="select * from $tabla";
$qry=mysql_query($consulta);
while($row=mysql_fetch_row($qry)){
	echo "
              <tr>
                <!--  <td width='34'><label>
                <input type='checkbox' name='checkbox' id='checkbox' /> -->
                </label></td>
                ";
                 for ($i = 0; $i+1 <= count ($campos_tabla); $i++) {
                 	if($i==3){
                 		echo " <td><a href='mailto:$row[$i]'>$row[$i]</a></td>";
                 	}
					else{
                     echo "<td>$row[$i]</td>";
				 		}
                 }
				echo "             
                <td width='90'></a> <a href='?sec=mantencion&subsec=$nombre_subsec&editar=$row[0]' class='edit_icon' title='Editar'></a> <a href='?sec=mantencion&subsec=$nombre_subsec&borrar=$row[0]' class='delete_icon' title='Borrar'></a></td>
              </tr>
";
}
?>                           
              <tr class="footer">
              </tr>
            </tbody>
          </table>
<a href="#login-box-<?php echo $prefijo;?>" class="button_ok" id="boton" ><span>Agregar</span></a><a href="mantenedores/imprimir.php?imprimir=<?php echo $nombre_subsec;?>" class="button_imprimir"><span>Imprimir</span></a>
        </form>
		</div>
      </div>
      <!-- pop up -->
<!--  END #PORTLETS -->  
   </div>
    <div class="clear"> </div>
<!-- END CONTENT-->    
  </div>
 
